package com.ajie.controller;


import com.ajie.entity.SysRole;
import com.ajie.service.SysRoleService;
import com.ajie.utils.QueryInfo;
import com.ajie.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 角色数据控制层
 */
@RestController
@Api(tags = "角色数据")
@RequestMapping("/role")
@Slf4j
public class SysRoleController {

    @Autowired
    private SysRoleService roleService;


    @ApiOperation(value = "分页查询")
    @PostMapping("/findPage")
    public Result findPage(@RequestBody QueryInfo queryInfo){
        log.info("该文件名是：SysRoleController,该方法是：findPage");
        return roleService.findPage(queryInfo);
    }

    @ApiOperation(value = "添加角色")
    @PostMapping("/insert")
    public Result insert(@RequestBody SysRole role){
        log.info("该文件名是：SysRoleController,该方法是：insert");
        return roleService.insert(role);
    }

    @ApiOperation(value = "删除角色")
    @DeleteMapping("/delete/{id}")
    public Result delete( @PathVariable("id") Long id){
        log.info("该文件名是：SysRoleController,该方法是：delete");
        return roleService.delete(id);
    }

    @ApiOperation(value = "修改角色")
    @PutMapping("/update")
    public Result update(@RequestBody SysRole role){
        log.info("该文件名是：SysRoleController,该方法是：update");
        return roleService.update(role);
    }
    
    @ApiOperation(value = "查询所有角色")
    @GetMapping("/findAllRoles")
    public Result findAllRoles(){
        log.info("该文件名是：SysRoleController,该方法是：findAllRoles");
        return  roleService.findAllRoles();
    }
    
    


}
